/******************************************************************************
 * The contents of this file are subject to the   JDI License  Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Initial Developer of the Original Code is 陈慧然. Portions created by 
 * 陈慧然 are Copyright 陈慧然.
 * All Rights Reserved.
 *
 *              Contact john_holen@163.com for licensing alternatives.
 *
 *****************************************************************************/


package org.peony.client.web.components.form;

import org.peony.client.web.components.WebComponents;
import org.peony.exceptions.RenderException;
import org.peony.tools.StringUtil;

/**
 *  
 *
 *  @author     陈慧然
 *  @version    Id: Radio.java, v 0.000 2008-5-5 上午09:39:57 陈慧然 Exp
 */
public class Radio extends WebComponents{
	private boolean isDefault = false;
	private String dataValue;
	private String groupName;
	private boolean isDisabled = false;
	private Label label;
	@Override
	public String toStandardString() throws RenderException {
		if(StringUtil.isEmpty(getId()))
			throw new RenderException("Radio (A Component) Can NOT has no id!");
		StringBuffer sb = new StringBuffer();
		sb.append(getLabel()==null?empty:getLabel().toStandardString());
		sb.append("<input type=\"radio\"")
			.append(" id= \"").append(getId()).append("\"")
			.append(" name=\"").append(getGroupName()).append("\"")
			.append(" value=\"").append(getDataValue()).append("\"")
			.append(StringUtil.isNotEmpty(getUIClass())?" class=\"" + getUIClass()+"\"":empty)
			.append(isDefault()?" checked==\"checked\"":empty)
			.append(isDisabled()?" disabled=\"disabled\"":empty)
			.append(" />");
		return sb.toString();
	}
	public boolean isDefault() {
		return isDefault;
	}
	public void setDefault(boolean isDefault) {
		this.isDefault = isDefault;
	}
	public String getDataValue() {
		return dataValue;
	}
	public void setDataValue(String dataValue) {
		this.dataValue = dataValue;
	}
	public String getGroupName() {
		return groupName;
	}
	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}
	public boolean isDisabled() {
		return isDisabled;
	}
	public void setDisabled(boolean isDisabled) {
		this.isDisabled = isDisabled;
	}
	public Label getLabel() {
		return label;
	}
	public void setLabel(Label label) {
		this.label = label;
	}
}
